package com.bms;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class Assignment5App extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    public void accept(View view) {
    	EditText ev = (EditText)findViewById(R.id.edtInput); 
    	
    	TextView textView = new TextView(this);
    	textView.setText(ev.getText());
    	textView.setGravity(Gravity.CENTER);
    	//In release code you would use a ratio based on the dimensions of the screen
    	textView.setMinWidth((int)(getWindowManager().getDefaultDisplay().getWidth() / 2));
    	
    	AlertDialog.Builder builder = new AlertDialog.Builder(this);
    	builder.setView(textView);
    	builder.setCancelable(false);
    	builder.setPositiveButton("Dismiss", new DialogInterface.OnClickListener() 
    		{
	           public void onClick(DialogInterface dialog, int id) 
	           {
	                dialog.dismiss();
	           }
	        });
    	builder.show();
    }
    
    public void clear(View view) {
    	EditText ev = (EditText)findViewById(R.id.edtInput);
    	ev.setText(R.string.clear);
    }
}